<?php

namespace app\controller;

use app\amqp\customer\TestCustomer;
use app\amqp\producer\DelayProducer;
use app\amqp\producer\TestProducer;
use app\BaseController;

class Index extends BaseController
{
    public function index()
    {
        $testProducer = new TestProducer();
        $data = json_encode(['id' => 1]);
        $testProducer->publish(TestCustomer::EXCHANGE_NAME, TestCustomer::ROUTING_KEY, $data);

        return json(['info' => 'ok']);
    }

    public function delay()
    {
        $producer = new DelayProducer();
        $data = json_encode(['id' => 1]);
        $producer->publish($data, 'delay_queue', 'delay_queue');

        return json(['info' => 'ok']);
    }
}
